#ifndef FILESYSTEM_H_
#define FILESYSTEM_H_
#include "Disk.h"
#include "Directory.h"

class FileSystem
{
private:
	Disk* disk;
	int blockSize;
public:
	FileSystem(Disk* disk);
	virtual ~FileSystem();

	int incNumHardLinks(int inode);
	int getNumHardLinks(int inode);
	void status();

	// creates a file returning its i-node number.
	//Flag indicates whether the file to create is a regular file or a soft link.
	int createFile(int flag);

	//– creates a directory, returning its i-node number.
	int createDir();

	 //– Returns the type of the file this i-node represents.
	int getFileType(int inode);

	//– Returns the size of the file this i-node represents.
	int getFileSize(int inode);

	//– reads nBytes (at most) from the given file (represented by this i-node) at the given offset inside the file into the buffer.
	int f_read( int inode, byte* buffer, int offset, int nBytes );

	//int Notice that both f_read and f_write only work on normal files (not directories).
	//– writes nBytes (at most) to the given file (represented by this i-node) at the given offset inside that file,
	//from the buffer. If the amount to be written exceeds the current allocated block, a new block should be allocated to
	//accommodate the rest of the data.
	int f_write( int inode, const byte* buffer, int offset, int nBytes );

	//– reads the entire content of the directory file specified by the given i-node.
	//This information is then entered into a data structure (a vector or list) that lists
	//the files in this directory. Each element in this list therefore contains a filename
	//and i-node number.
	Directory* d_read(int inode);

	// – replaces the content of the given directory file (specified by i-node)
	//with the information stored in the list.
	//The list has the same format as that returned by d_read().
	int d_write(int inode, Directory* dir );

	//– delete the file.
	int f_delete(int inode) ;

	//– delete the directory if it is empty.
	int d_delete(int inode);


};

bool test_FileSystem();

#endif /*FILESYSTEM_H_*/
